//
//  UIImage+CK_ShutScreen.m
//  
//
//  Created by lanou3g on 15/10/26.
//
//

#import "UIImage+CK_ShutScreen.h"

@implementation UIImage (CK_ShutScreen)

+ (instancetype)captureWithView:(UIView *)view
{
    UIGraphicsBeginImageContextWithOptions(view.frame.size, NO, 0.0);
    [view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return newImage;
}

+ (instancetype)captureWithShareView:(UIView *)view
{
    CGSize size = CGSizeMake(view.frame.size.width, view.frame.size.height*0.9);
    UIGraphicsBeginImageContextWithOptions(size, NO, 2.0);
    [view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    //[UIImagePNGRepresentation(newImage) writeToFile:@"/Users/wangyituo/Desktop/1.png" atomically:YES];
    return newImage;
}



// basic64编码
//    //562df776e697fa8b7e8b457d
//    NSString *str1 = @"562df776e697fa8b7e8b457d";
//    NSData *data = [str1 dataUsingEncoding:NSUTF8StringEncoding];
//    NSString *str2 = [data base64EncodedStringWithOptions:0];
//    NSLog(@"%@", str2);


+ (void)saveToPhotoAlbumWithImage:(UIImage *)image
{
    UIImageWriteToSavedPhotosAlbum(image, self, nil, nil);
}

@end
